app.controller('bpmProcessStartController', ['$scope', 'httpWrapService', '$state', '$stateParams','uiGridConstants','GridFactory', 'AlertFactory','dialogs',
        function($scope, httpWrapService, $state, $stateParams,uiGridConstants, GridFactory, AlertFactory, dialogs) {

    $scope.Alert = AlertFactory.newInstance();
    $scope.processDefinitionId = $stateParams.processDefinitionId;
    $scope.map = {};

    $scope.formData = {};

    $scope.load = function(processDefinitionId){
        httpWrapService.post('bpm/process/getform/start.do',{
            processDefinitionId : processDefinitionId
        }).then(function (res) {
            $scope.map = res.data.map;
            if($scope.map.hasUsers) {
                httpWrapService.post('system/user/list.do',{}).then(function(res2){
                    $scope.userList = res2.data.data;
                });
            }
        });
    }
    $scope.load($scope.processDefinitionId);

    $scope.startUp = function(id){
        var data = {
            formData : $scope.formData,
            processDefinitionId : $scope.processDefinitionId
        }
        data.option = $scope.datapickerOption;
        httpWrapService.defaultSave('bpm/process/process_instance/start.do',data, $scope).then(function(res){
            $state.go('app.bpm.manager.processlist');
        });
    }

    $scope.canle = function () {
        // 后退到列表页面
        $state.go('app.bpm.manager.processlist');
    }

}]);